Internal definitions

Some implementations of Scheme permit definitions to occur at the beginning of a body (that is, the body of a lambda, let, let*, letrec, or define expression). Such definitions are known as internal definitions internal definition as opposed to the top level definitions described above. The variable defined by an internal definition is local to the body. That is, variable is bound rather than assigned, and the region of the binding is the entire body. For example,


\begin{scheme}
(let ((x 5))
(define foo (lambda (y) (bar x y)))
(define bar (lambda (a b) (+ (* a b) a)))
(foo (+ x 3))) \ev 45\end{scheme}

A body containing internal definitions can always be converted into a completely equivalent letrec expression. For example, the let expression in the above example is equivalent to


\begin{scheme}
(let ((x 5))
(letrec ((foo (lambda (y) (bar x y)))
(bar (lambda (a b) (+ (* a b) a))))
(foo (+ x 3))))%
\end{scheme}

Say something about why definitions aren't allowed in sequence expressions? (For macros, a.k.a. the ``progn compile hack''.)